﻿using System;
using System.Linq;

class MaximalSequenceOfEqualElements
{
    static void Main()
    {
        Console.Write("Number of elements of array:");
        int arrayLength = int.Parse(Console.ReadLine());
        int[] array = new int[arrayLength];
        for (int i = 0; i < array.Length; i++)
        {
            Console.Write("\nChar element a[{0}]:", i);
            array[i] = int.Parse(Console.ReadLine());
        }
        //int[] array = { 2, 1, 1, 2, 3, 3, 2, 2, 2, 1 };

        int bestNumber = new int();
        int bestNumberRepetition = 1;

        int candidateNumber = new int();
        int candidateNumberRepetition = new int();

        for (int i = 0; i < array.Length - 1; i++)
        {
            if (array[i] == array[i + 1])
            {
                candidateNumber = array[i];
                candidateNumberRepetition++;
            }
            else
            {
                candidateNumberRepetition = 1;
            }
            if (candidateNumberRepetition >= bestNumberRepetition)
            {
                bestNumber = candidateNumber;
                bestNumberRepetition = candidateNumberRepetition;
            }
        }

        Console.WriteLine("Best sequence is {0} time(s) number {1}!",bestNumberRepetition,bestNumber);
    }
}